package com.levelup.cr.dao.impl;

import com.levelup.cr.model.bridge.NodeProxyResolver;
import com.levelup.cr.dao.NodeReader;
import com.levelup.cr.model.Node;
import com.levelup.cr.model.NodeProxy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.io.File;

/**
 * Created with IntelliJ IDEA.
 * User: denis_zavadsky
 * Date: 9/5/13
 * Time: 7:21 PM
 * To change this template use File | Settings | File Templates.
 */
@Component("nodeProxyResolver")
@Scope("prototype")
public class NodeProxyResolverImpl implements NodeProxyResolver {

    @Autowired
    private NodeReader nodeReader;

    public void setNodeReader(NodeReader nodeReader) {
        this.nodeReader = nodeReader;
    }

    @Override
    public Node initialize(NodeProxy proxy) {
        return nodeReader.readNodeByPath(proxy.getParentPath()+ File.separator+proxy.getName());

    }
}
